package com.changanhua.io.file;

import java.nio.charset.StandardCharsets;

/**
 * 测试不同字符占据字节个数
 *
 * @author changanhua
 */
public class StandardCharsetsDemo {

    public static void main(String[] args) {
        System.out.println("中".getBytes(StandardCharsets.UTF_8).length);
        System.out.println("中".getBytes(StandardCharsets.UTF_16).length);

        System.out.println("中".getBytes(StandardCharsets.ISO_8859_1).length);
        System.out.println("中".getBytes(StandardCharsets.US_ASCII).length);







        System.out.println("\r".getBytes(StandardCharsets.UTF_8).length);
        System.out.println("\n".getBytes(StandardCharsets.UTF_8).length);
        System.out.println("H".getBytes(StandardCharsets.UTF_8).length);
        System.out.println("h".getBytes(StandardCharsets.UTF_8).length);
        System.out.println(" ".getBytes(StandardCharsets.UTF_8).length);
    }

}
